package com.glodon.paas.document.dao.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.glodon.paas.consts.StringConst;
import com.glodon.paas.document.api.bean.ProjectResource;
import com.glodon.paas.document.api.bean.ProjectRole;

public class ProjectResourceEntity {

    private String id;
    private String fileId;
    private String resource;
    private String roleId;
    private String privileges;
    private String updatorId;
    private Date updateTime;
    
    public static ProjectResource getDto(ProjectResourceEntity e) {
        if (e == null) {
            return null;
        } else {
            ProjectResource d = new ProjectResource();
            d.setFileId(e.getFileId());
            d.setPrivileges(e.getPrivileges().split(StringConst.SEPARATOR_COMMA));
            d.setResource(e.getResource());
            ProjectRole role = new ProjectRole();
            role.setId(e.getRoleId());
            d.setRole(role);
            return d;
        }
    }
    
    public static List<ProjectResource> getDtos(List<ProjectResourceEntity> es) {
        if (es == null) {
            return null;
        } else {
            List<ProjectResource> ds = new ArrayList<ProjectResource>(es.size());
            for (ProjectResourceEntity e : es) {
                ds.add(getDto(e));
            }
            return ds;
        }
    }
    
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getResource() {
        return resource;
    }

    public void setResource(String resource) {
        this.resource = resource;
    }

    public String getRoleId() {
        return roleId;
    }

    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }

    public String getPrivileges() {
        return privileges == null ? "" : privileges;
    }

    public void setPrivileges(String privileges) {
        this.privileges = privileges;
    }

    
    public String getFileId() {
        return fileId;
    }

    
    public void setFileId(String fileId) {
        this.fileId = fileId;
    }
    
    public String getUpdatorId() {
        return updatorId;
    }

    
    public void setUpdatorId(String updatorId) {
        this.updatorId = updatorId;
    }

    
    public Date getUpdateTime() {
        return updateTime;
    }
    
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
